﻿using System;
using System.Collections.Generic;

namespace FallingRocks
{
    class MenuConsoleRenderer :IRenderer
    {
        public void RenderObjects(List<IRenderable> renderableObjects)
        {
            foreach (IRenderable renderableObject in renderableObjects)
            {
                Console.SetCursorPosition(renderableObject.Position.X, renderableObject.Position.Y);
                Console.ForegroundColor = this.MatchColor(renderableObject.Color);
                Console.Write(renderableObject.Visualisation);
            }
        }

        private ConsoleColor MatchColor(Color color)
        {
            ConsoleColor matchColor;

            switch (color)
            {
                case Color.Cyan:
                    matchColor = ConsoleColor.Cyan;
                    break;
                case Color.Blue:
                    matchColor = ConsoleColor.Blue;
                    break;
                case Color.Green:
                    matchColor = ConsoleColor.Green;
                    break;
                case Color.Red:
                    matchColor = ConsoleColor.Red;
                    break;
                case Color.Magenta:
                    matchColor = ConsoleColor.Magenta;
                    break;
                case Color.Yellow:
                    matchColor = ConsoleColor.Yellow;
                    break;
                default:
                    matchColor = ConsoleColor.White;
                    break;
            }

            return matchColor;
        }
    }
}
